#pragma once
#include <GL/glew.h>
#include <GL/glut.h>

#include <QGLWidget>
#include <qglshaderprogram.h>
#include "Puma.h"

#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>

#pragma comment(lib, "glew32.lib")
#pragma comment(lib, "opengl32.lib")

class GLWidget :
	public QGLWidget
{
	Q_OBJECT
public:
	GLWidget(const QGLFormat & format, QWidget *parent);
	~GLWidget(void);

	QSize minimumSizeHint() const;
    QSize sizeHint() const;

public slots:
	void setXRotation(int angle);
	void setYRotation(int angle);
	void setZRotation(int angle);

protected:
    void initializeGL();
    void paintGL();
    void resizeGL(int width, int height);
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
	void keyPressEvent ( QKeyEvent * event );
	void wheelEvent ( QWheelEvent * event );

	bool prepareShaders();
	bool initShader(QGLShaderProgram& shader, const QString& fragFile, const QString& vertFile, const QString& geomFile);
	void draw();

private:
	QPoint lastPos;

	QGLShaderProgram mShaderProgram;
	QMatrix4x4 projectionMatrix;
	QMatrix4x4 viewMatrix;
	// work data
	PUMA::Puma puma;
};

